M Hallett
January 2015
It is a GNU project which is similar to the S language developed at Bell Laboratories by Jo hn Chambers et al.
R and it's assocaited packages togetherprovide a wide variety of functionalties:
(if you want to… not necessary but sometimes easier)
Available @ CRAN (Comprehensive R Archive Network) Vers 3.1.2
R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin10.8.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
>
Stackoverflow.com is really good. Most common questions have aleady been asked and answered.terminal window (look under Applications).Download PuTTY: \( {\tt http://www.chiark.greenend.org.uk/\tilde{}sgtatham/putty/download.html} \)
You need the development version v. 0.64 as there is a bug in the stable release.
ssh -f <socs_username>@rstudio.cs.mcgill.ca -L 8787:rstudio.cs.mcgill.ca:8787 -N
(You don't really need to understand this step.)
Chrome. Don't use Explorer.) localhost:8787.localhost is how a browser points to a site
within the same computer.Tools/Shell.pwd command to see where you are.git clone /repo/COMP364/2015/Winter/student-repo.git ~/cs364
When this finishes execution, a copy (clone) of all the files that Dani and I created for the course will be in a directory in your home (~). You can read, write, modify, add, and delete these files as you want.
ls
total 8
drwxr-xr-x 3 hallett nogroup 3 Jan 11 13:41 R
drwxr-xr-x 8 hallett nogroup 9 Jan 12 14:10 cs364
So there are now two directories… the newest is cs364 that you just cloned. The other was created by R for its own internal purposes. Ignore it.
cd cs364
Change directory (cd) into the cs364 directory that you just cloned.
ls
total 17
-rw-r–r– 1 hallett nogroup 91 Jan 12 14:10 README
drwxr-xr-x 2 hallett nogroup 3 Jan 12 14:10 assignments
drwxr-xr-x 2 hallett nogroup 8 Jan 12 14:10 data
drwxr-xr-x 2 hallett nogroup 3 Jan 12 14:10 experiments
drwxr-xr-x 2 hallett nogroup 3 Jan 12 14:10 lectures
drwxr-xr-x 2 hallett nogroup 4 Jan 12 14:10 src
Change directory (cd) into the cs364 directory that you just cloned.
cat README
…
The cat (concatenate) commands allows you to look at the contents of a text file.
README files are sort of standard for providing users in Unix with important information about files.
cd lectures
ls -l
But it's easier to examine these files using the bottom-right RStudio window (Files).
File/New Project/Existing Directory/Browse.cs364.Git.Commit, your files will be securely saved.The nice thing about using GIT is that it allows us to smoothly update, fix and modify the course notes, data and R scripts.
Git panel and hit the Pull button.Tools/Shell.cd ~/cs364 or wherever you created your cs364 directory.git pullIn other words, cd (change directory) to the place where you initially cloned the student cs364 directory (the previous slides suggest ~/cs364). The pull commands “pulls” all the updates, modifications and additions that Dani or I have made and merges them with your file, seemlesssly.
topu <username> sshkill -9 <process id> ssh -f <ur socs username>@rstudio.cs.mcgill.ca -L 8787:rstudio.cs.mcgill.ca:8787 -N terminal window (look under Applications).
ssh -l <ur socs username> rstudio.cs.mcgill.ca
(You will be prompted for your password.)
Tools/shell within RStudio.cd
cd = “change directory”. When you type this alone, you are sent back to your home.
cd ~
The tilde is a symbol meaning your come. Executing “cd” and “cd ~” are the same.
ls
cs364 R
“ls = list. This lists all the files & directories in your currently location.
cd ~/cs364
This moves you down one level of the tree into your cs364 directory.
ls -l
total 19
drwxr-xr-x 2 hallett nogroup 3 Jan 12 14:10 assignments
-rw-r--r-- 1 hallett nogroup 205 Jan 12 14:29 cs364.Rproj
drwxr-xr-x 2 hallett nogroup 8 Jan 12 14:10 data
drwxr-xr-x 2 hallett nogroup 3 Jan 12 14:10 experiments
drwxr-xr-x 3 hallett nogroup 5 Jan 12 14:25 lectures
-rw------- 1 hallett nogroup 0 Jan 12 14:57 my.new.lecture
-rw-r--r-- 1 hallett nogroup 91 Jan 12 14:10 README
drwxr-xr-x 2 hallett nogroup 4 Jan 12 14:10 src
cat README
This is the course repository. Each directory contains a brief description of its purpose.
cat = concatenate. Print the contents of a text file.
cd lectures
This moves you down another level of the tree.
pwd
/home/2015/hallett/cs364/lectures
print working directory. This tells you where you are in your tree.
touch my.new.lecture
touch creates an empty file with the given name.
ls -l
total 18959
-rw-r--r-- 1 hallett nogroup 48 Jan 12 14:10 lectures-readme.txt
drwx------ 3 hallett nogroup 5 Jan 12 14:23 M1.L1
-rw------- 1 hallett nogroup 19319296 Jan 12 14:24 M1.L2.ppt
-rw------- 1 hallett nogroup 0 Jan 12 2015 my.new.lecture
mv my.new.lecture ~/my.new.lecture.moved
mv = move. This moves the file “my.new.lecture” to a new location (my home directory ~) and a new name “my.new.lecture.moved”.
ls -l
total 18958
-rw-r--r-- 1 hallett nogroup 48 Jan 12 14:10 lectures-readme.txt
drwx------ 3 hallett nogroup 5 Jan 12 14:23 M1.L1
-rw------- 1 hallett nogroup 19319296 Jan 12 14:24 M1.L2.ppt
cd ~
Let's move back to the top where we moved the file.
ls -l
total 8
drwxr-xr-x 9 hallett nogroup 13 Jan 12 14:57 cs364
-rw------- 1 hallett nogroup 0 Jan 12 15:12 my.new.lecture.moved
drwxr-xr-x 3 hallett nogroup 3 Jan 11 13:41 R
-rw-r--r-- 1 hallett nogroup 5 Jan 11 14:02 tmp.R
cp my.new.lecture.moved didntmove.again
cp=copy. It makes a copy (but doesn't destroy the original) of a file. The second argument is the name of the file.
ls -l
total 9
drwxr-xr-x 9 hallett nogroup 13 Jan 12 14:57 cs364
-rw------- 1 hallett nogroup 0 Jan 12 2015 didntmove.again
-rw------- 1 hallett nogroup 0 Jan 12 15:12 my.new.lecture.moved
drwxr-xr-x 3 hallett nogroup 3 Jan 11 13:41 R
-rw-r--r-- 1 hallett nogroup 5 Jan 11 14:02 tmp.R
rm my.new.lecture.moved
rm=remove. This removes the specified file. Unix might prompt you to be sure.
ls -l
total 8
drwxr-xr-x 9 hallett nogroup 13 Jan 12 14:57 cs364
-rw------- 1 hallett nogroup 0 Jan 12 15:16 didntmove.again
drwxr-xr-x 3 hallett nogroup 3 Jan 11 13:41 R
-rw-r--r-- 1 hallett nogroup 5 Jan 11 14:02 tmp.R
cd ~
cp -r cs364 cs364.backup
The -r flag means “recursive”: Copy cs364 and all the files/directories within cs364 and all the files/directories within each directory within cs364, etc. etc. etc.
ls -l
total 11
drwxr-xr-x 9 hallett nogroup 13 Jan 12 14:57 cs364
drwx------ 9 hallett nogroup 13 Jan 12 2015 cs364.backup
-rw------- 1 hallett nogroup 0 Jan 12 15:16 didntmove.again
drwxr-xr-x 3 hallett nogroup 3 Jan 11 13:41 R
-rw-r--r-- 1 hallett nogroup 5 Jan 11 14:02 tmp.R
rm -r cs364.backup
rm: descend into directory ‘cs364.backup/’? y
The -r flag again means “recursive”. but this will take a long time…
rm: descend into directory ‘cs364.backup/src’? y
rm: remove regular file ‘cs364.backup/src/src-readme.txt’?
rm -r -f cs364.backup
The -f flag again means force the remove (don't ask for permission).
top
top - 16:04:53 up 7 days, 1:57, 3 users, load average: 0.00, 0.02, 0.05
KiB Mem: 8176704 total, 2137472 used, 6039232 free, 165264 buffers
KiB Swap: 8388604 total, 0 used, 8388604 free. 1660936 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 35592 2904 1480 S 0.0 0.0 0:02.52 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.52 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root 20 0 0 0 0 S 0.0 0.0 0:21.18 rcusched
_All the processes running on the machine. Everyone's.
top
u hallett
top - 16:04:53 up 7 days, 1:57, 3 users, load average: 0.00, 0.02, 0.05
Just my processes.
Tasks: 120 total, 1 running, 119 sleeping, 0 stopped, 0 zombie
...
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2307 hallett 20 0 124732 2040 1000 S 0.0 0.0 0:00.09 sshd
2308 hallett 20 0 33600 4144 1976 S 0.0 0.1 0:00.08 bash
kill -9 2307
Kills my process with PID (process ID) 2307.